#!/usr/bin/env python
# -*- coding: utf-8 -*-

from typing import Any

from cta.interface.action.log.abstract_log_action import AbstractLogAction
from web.constants.datetime_format import DatetimeFormat
from web.domain.responsibility_chain_dto import ResponsibilityChainDto
from web.manager.log_manager import LogManager
from web.models.optimize2_account import Optimize2Account
from web.models.quant2_account import Quant2Account
from web.util.datetime_util import DatetimeUtil

Logger = LogManager.get_logger(__name__)

class Optimize2LogAction(AbstractLogAction):
    """
    记录日志
    """

    def exec(self, responsibility_chain_dto: ResponsibilityChainDto = None) -> Any:
        Logger.info("记录日志")

        transaction_date: str = responsibility_chain_dto.transaction_date

        # 返回量化账户
        optimize2_account_list: list[Optimize2Account] = self.optimize2_account_dao.find_all()

        for optimize2_account in optimize2_account_list:
            self.optimize2_account_log_dao.insert(transaction_date, optimize2_account.account_name)

        super().next(responsibility_chain_dto)